#include "stdafx.h"
#pragma hdrstop

#include "OSEvent.h"

OSEvent::OSEvent()
{
	mHandle = ::CreateEvent(NULL, true, false, NULL);
}

OSEvent::~OSEvent()
{
	if(mHandle != NULL)
		::CloseHandle(mHandle);
}

bool OSEvent::Set()
{
	return ::SetEvent(mHandle);
}

bool OSEvent::Reset()
{
	return ::ResetEvent(mHandle);
}

bool OSEvent::Wait(int inTimeout_ms)
{
	DWORD timeout = inTimeout_ms >= 0? inTimeout_ms:cInfiniteTimeout;

	return (::WaitForSingleObject(mHandle, timeout) == WAIT_OBJECT_0);
}